use thiserror::Error;

pub type IoErr = std::io::Error;
pub type JniErr = jni::errors::Error;
pub type CborErr = serde_cbor::Error;

#[derive(Debug, Error)]
pub enum AppErr {

    #[error("io:{0}")]
    Io(#[from] IoErr),

    #[error("close:{0}")]
    Closed(&'static str),

    #[error("proto:{0}")]
    Proto(&'static str),

    #[error("{0}")]
    Custom(&'static str),

    #[error("jni:{0}")]
    Jni(#[from] JniErr),

    #[error("cbor:{0}")]
    Cbor(#[from] CborErr),
}

pub fn new_err(msg: &'static str) -> AppErr {
    AppErr::Custom(msg)
}















